/* *************************************** */
/* * Complete Graph Generator            * */
/* * Authors:                            * */
/* *  André Bannwart Perina      7152757 * */
/* *  Rodrigo de Freitas Pereira 7573472 * */
/* *  Thaís Emanuele dos Santos  6453087 * */
/* *************************************** */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	/* Wrong number of arguments */
	if(3 != argc) {
		fprintf(stderr, "Usage: %s n filename\n", argv[0]);
		exit(1);
	}

	int i, j, n = atoi(argv[1]);
	FILE *ipf = fopen(argv[2], "w");

	srand(time(NULL));

	/* Print number of nodes and number of edges (complete graph has (n(n-1))/2 edges) */
	fprintf(ipf, "%d %d\n", n, (n*(n-1))/2);

	/* Print all edges with random weight */
	for(i = 0; i < n; i++) {
		for(j = i; j < n; j++) {
			if(i != j)
				fprintf(ipf, "%d %d %d\n", i+1, j+1, rand() % 100);
		}
	}

	/* Close file */
	fclose(ipf);

	return 0;
}